home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / windows / ocx / ipack.exe / GOPHERS.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-10-20  |  10.2 KB  |  295 lines

  1. VERSION 4.00
  2. Begin VB.Form GopherS 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Gopher Sample"
  6.    ClientHeight    =   4635
  7.    ClientLeft      =   2160
  8.    ClientTop       =   2250
  9.    ClientWidth     =   9540
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   0
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   5040
  21.    Left            =   2100
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   4635
  24.    ScaleWidth      =   9540
  25.    Top             =   1905
  26.    Width           =   9660
  27.    Begin VB.CommandButton cmdExit 
  28.       Appearance      =   0  'Flat
  29.       BackColor       =   &H80000005&
  30.       Cancel          =   -1  'True
  31.       Caption         =   "E&xit"
  32.       BeginProperty Font 
  33.          name            =   "MS Sans Serif"
  34.          charset         =   0
  35.          weight          =   400
  36.          size            =   8.25
  37.          underline       =   0   'False
  38.          italic          =   0   'False
  39.          strikethrough   =   0   'False
  40.       EndProperty
  41.       Height          =   375
  42.       Left            =   6960
  43.       TabIndex        =   3
  44.       Top             =   720
  45.       Width           =   2295
  46.    End
  47.    Begin VB.CommandButton cmdBack 
  48.       Appearance      =   0  'Flat
  49.       BackColor       =   &H80000005&
  50.       Caption         =   "Go &Back"
  51.       BeginProperty Font 
  52.          name            =   "MS Sans Serif"
  53.          charset         =   0
  54.          weight          =   400
  55.          size            =   8.25
  56.          underline       =   0   'False
  57.          italic          =   0   'False
  58.          strikethrough   =   0   'False
  59.       EndProperty
  60.       Height          =   375
  61.       Left            =   6960
  62.       TabIndex        =   1
  63.       Top             =   240
  64.       Width           =   2295
  65.    End
  66.    Begin VB.ListBox lstMenu 
  67.       Appearance      =   0  'Flat
  68.       BeginProperty Font 
  69.          name            =   "MS Sans Serif"
  70.          charset         =   0
  71.          weight          =   400
  72.          size            =   8.25
  73.          underline       =   0   'False
  74.          italic          =   0   'False
  75.          strikethrough   =   0   'False
  76.       EndProperty
  77.       Height          =   3930
  78.       Left            =   240
  79.       TabIndex        =   0
  80.       Top             =   480
  81.       Width           =   6375
  82.    End
  83.    Begin GopherLib.Gopher Gopher1 
  84.       Left            =   9120
  85.       Top             =   4200
  86.       _Version        =   327680
  87.       _ExtentX        =   847
  88.       _ExtentY        =   847
  89.       _StockProps     =   64
  90.       Blocking        =   -1  'True
  91.       Host            =   "gopher.uiuc.edu"
  92.       Port            =   70
  93.       Selector        =   ""
  94.       Type            =   "1"
  95.       OutputFilename  =   "C:\~~GOPHER.TXT"
  96.    End
  97.    Begin VB.Label Label2 
  98.       Appearance      =   0  'Flat
  99.       BackColor       =   &H80000005&
  100.       BackStyle       =   0  'Transparent
  101.       Caption         =   $"gophers.frx":0000
  102.       BeginProperty Font 
  103.          name            =   "MS Sans Serif"
  104.          charset         =   0
  105.          weight          =   400
  106.          size            =   8.25
  107.          underline       =   0   'False
  108.          italic          =   0   'False
  109.          strikethrough   =   0   'False
  110.       EndProperty
  111.       ForeColor       =   &H80000008&
  112.       Height          =   3135
  113.       Left            =   6960
  114.       TabIndex        =   4
  115.       Top             =   1320
  116.       Width           =   2295
  117.    End
  118.    Begin VB.Label Label1 
  119.       Appearance      =   0  'Flat
  120.       BackColor       =   &H80000005&
  121.       BackStyle       =   0  'Transparent
  122.       Caption         =   "Current Menu:"
  123.       BeginProperty Font 
  124.          name            =   "MS Sans Serif"
  125.          charset         =   0
  126.          weight          =   400
  127.          size            =   8.25
  128.          underline       =   0   'False
  129.          italic          =   0   'False
  130.          strikethrough   =   0   'False
  131.       EndProperty
  132.       ForeColor       =   &H80000008&
  133.       Height          =   255
  134.       Left            =   240
  135.       TabIndex        =   2
  136.       Top             =   240
  137.       Width           =   2775
  138.    End
  139. Attribute VB_Name = "GopherS"
  140. Attribute VB_Creatable = False
  141. Attribute VB_Exposed = False
  142. Option Explicit
  143. ' Storage for the Back button.
  144. Dim BackIndex
  145. Dim BackType(1 To 100) As String
  146. Dim BackHost(1 To 100) As String
  147. Dim BackPort(1 To 100) As Integer
  148. Dim BackSelector(1 To 100) As String
  149. Private Sub cmdBack_Click()
  150.     ' If we don't have any sites in the back list,
  151.     ' beep and exit, doing nothing.
  152.     If BackIndex < 1 Then
  153.         Beep
  154.         Exit Sub
  155.         End If
  156.     ' Move to the new site and move back in the back list.
  157.     NewSite BackHost(BackIndex), BackPort(BackIndex), BackType(BackIndex), BackSelector(BackIndex)
  158.     BackIndex = BackIndex - 1
  159.     End Sub
  160. Private Sub cmdExit_Click()
  161.     Unload Me
  162.     End Sub
  163. Private Sub Form_Load()
  164.     Me.Caption = "Gopher Sample - " & Gopher1.Host & "\" & Gopher1.Selector
  165.     ' Load the initial menu.
  166.     Gopher1.Action = 1
  167.     MenuLoad
  168.     ' Nothing to go back to, yet.
  169.     BackIndex = 0
  170.     End Sub
  171. Private Sub Form_Unload(Cancel As Integer)
  172.     ' Remove out temporary file (if any).
  173.     On Error Resume Next
  174.     Kill "C:\~~GOPHER.TXT"
  175.     On Error GoTo 0
  176.     End
  177.     End Sub
  178. Private Sub lstMenu_DblClick()
  179.     Dim ItemIndex As Integer
  180.     ' Did the user click on an item in the menu?
  181.     ' If not, beep and bail.
  182.     If lstMenu.ListIndex < 0 Then
  183.         Beep
  184.         Exit Sub
  185.         End If
  186.     ' Get the index of the menu item from the list
  187.     ' which acts as our menu.  This index is
  188.     ' stored in ItemData to allow us to sort
  189.     ' the list (if desired).
  190.     ItemIndex = lstMenu.ItemData(lstMenu.ListIndex)
  191.     Select Case Gopher1.ItemType(ItemIndex)
  192.         Case "0", "1", "7"
  193.             Dim I
  194.             ' If our Back list is full, drop an
  195.             ' element from the list so that it
  196.             ' won't overflow.
  197.             If BackIndex >= 100 Then
  198.                 For I = 1 To 99
  199.                     BackType(I) = BackType(I + 1)
  200.                     BackHost(I) = BackHost(I + 1)
  201.                     BackPort(I) = BackPort(I + 1)
  202.                     BackSelector(I) = BackSelector(I + 1)
  203.                     Next I
  204.                 BackIndex = 99
  205.                 End If
  206.             ' Save the current information for
  207.             ' going back.
  208.             BackIndex = BackIndex + 1
  209.             BackType(BackIndex) = Gopher1.Type
  210.             BackHost(BackIndex) = Gopher1.Host
  211.             BackPort(BackIndex) = Gopher1.Port
  212.             BackSelector(BackIndex) = Gopher1.Selector
  213.         End Select
  214.     NewSite Gopher1.ItemHost(ItemIndex), Gopher1.ItemPort(ItemIndex), Gopher1.ItemType(ItemIndex), Gopher1.ItemSelector(ItemIndex)
  215.     End Sub
  216. Private Sub MenuLoad()
  217.     Dim I
  218.     ' Clear the user's menu.
  219.     lstMenu.Clear
  220.     ' Scan through all of the items in the Gopher menu.
  221.     For I = 1 To Gopher1.ItemCount
  222.         ' Put the current item into the user's menu
  223.         ' based on the item's type.
  224.         Select Case Gopher1.ItemType(I - 1)
  225.             Case "0"
  226.                 lstMenu.AddItem "Text File: " & Gopher1.ItemDescription(I - 1)
  227.                 lstMenu.ItemData(lstMenu.NewIndex) = I - 1
  228.             Case "1"
  229.                 lstMenu.AddItem "Menu: " & Gopher1.ItemDescription(I - 1)
  230.                 lstMenu.ItemData(lstMenu.NewIndex) = I - 1
  231.             Case "7"
  232.                 lstMenu.AddItem "Search: " & Gopher1.ItemDescription(I - 1)
  233.                 lstMenu.ItemData(lstMenu.NewIndex) = I - 1
  234.             Case Else
  235.                 lstMenu.AddItem "Unknown: " & Gopher1.ItemDescription(I - 1)
  236.                 lstMenu.ItemData(lstMenu.NewIndex) = I - 1
  237.             End Select
  238.         Next I
  239.     End Sub
  240. Private Sub NewSite(ByVal Host As String, ByVal Port As Integer, ByVal MenuType As String, ByVal Selector As String)
  241.     Dim Dummy
  242.     Screen.MousePointer = 11
  243.     On Error GoTo ErrorHandler
  244.     Select Case MenuType
  245.         Case "0"
  246.             ' This item is a text file.  Give the
  247.             ' Gopher control the address info for the
  248.             ' file.
  249.             Gopher1.Host = Host
  250.             Gopher1.Selector = Selector
  251.             Gopher1.Type = MenuType
  252.             Gopher1.Port = Port
  253.             ' Load the text file.  OutputFilename is
  254.             ' set in the design envinronment, in this
  255.             ' case.  You can set the OutputFilename
  256.             ' anytime you like.
  257.             Gopher1.Action = 1
  258.             Me.Caption = "Gopher Sample - " & Gopher1.Host & "/" & Gopher1.Selector
  259.             Dummy = Shell("NOTEPAD.EXE " & Gopher1.OutputFilename, 1)
  260.         Case "1"
  261.             ' If this item is a menu, load the
  262.             ' appropriate address into the Gopher
  263.             ' control.
  264.             Gopher1.Host = Host
  265.             Gopher1.Selector = Selector
  266.             Gopher1.Type = MenuType
  267.             Gopher1.Port = Port
  268.             ' Go to the new location and load the
  269.             ' new menu into our list box.
  270.             Gopher1.Action = 1
  271.             Me.Caption = "Gopher Sample - " & Gopher1.Host & "/" & Gopher1.Selector
  272.             MenuLoad
  273.         Case "7"
  274.             ' This is a search service.  Point to it,
  275.             ' get the word(s) to search from from the user,
  276.             ' then load anything returned.
  277.             Gopher1.Host = Host
  278.             Gopher1.Type = MenuType
  279.             Gopher1.Port = Port
  280.             Gopher1.Selector = InputBox$("Enter a word or words to search for.", "Gopher Search")
  281.             If Trim(Gopher1.Selector) <> "" Then
  282.                 Gopher1.Action = 1
  283.                 Me.Caption = "Gopher Sample - " & Gopher1.Host & "/" & Gopher1.Selector
  284.                 MenuLoad
  285.                 End If
  286.         End Select
  287.         
  288.     Screen.MousePointer = 0
  289.     Exit Sub
  290. ErrorHandler:
  291.     Screen.MousePointer = 0
  292.     MsgBox "Error " & Err & ": " & Error, 48, "Gopher Sample"
  293.     Exit Sub
  294.     End Sub
  295.